<?php
namespace Home\Controller;
use Think\Controller;

class ShowcarController extends Controller{
	public function showcar(){	
		$res = M('showcar')->where("status=0")->select();
		$shu = count($res);
		$this->assign("shu",$shu);
		$this->assign("res",$res);
		//print_r($res);
		$this->display();		
	}

	public function showcarDel(){
		$id = I('get.id');
		$res = M('showcar')->where("id={$id}")->delete();
		$r = array();
		if($res){
			$r['msg']='删除成功';
			$r['status']=true;
		}else{
			$r['msg']='删除失败';
			$r['status']=false;
		}
		$this->ajaxReturn($r);
	}

	public function showcarDelall(){
		$id = I('post.arr');
		$n = count($id);
		foreach($id as $v){
			$res = M('showcar')->where("id={$v}")->delete();
		}
		$r = array();
		if($res){
			$r['msg']='已成功删除'.$n.'条记录';
			$r['status']=true;
		}else{
			$r['msg']='删除失败';
			$r['status']=false;
		}
		$this->ajaxReturn($r);
	}
}